package com.jianganming.serial;

public class SerialDemo {
    public static void main(String[] args) {
        User user = new User();
        user.setName("江安明");
        user.setAge(30);
        serializer(user,new JavaSerializer());
        System.out.println("===============");
        serializer(user,new JavaSerializerWithFile());
        System.out.println("===============");
        serializer(user,new XStreamSerializer());
        System.out.println("---------------");
        serializer(user,new JsonSerializer());

    }

    private static void serializer(User user,ISerializer iSerializer){

        byte[] bytes = iSerializer.serialize(user);
        System.out.println(bytes.length);
        User user1 = iSerializer.deserialize(bytes, User.class);
        System.out.println(user1);
    }
}
